package com.example.bot.fun;

import com.alibaba.fastjson.JSONObject;
import com.example.bot.entity.Message;
import com.example.bot.entity.Params;
import com.example.bot.entity.Request;
import com.example.bot.event.IMessageEvent;
import com.example.bot.ws.Client;
import org.springframework.stereotype.Component;

@Component
public class TestFunB implements IMessageEvent {
    @Override
    public int weight() {
        return 10;
    }

    @Override
    public boolean onMessage(Message message) {
        if (!"签到".equals(message.getMessage())) {
            return false;
        }

        Request<Params> paramsRequest = new Request<>();
        paramsRequest.setAction("send_msg");
        Params params = new Params();
        params.setUser_id(message.getUser_id());
        params.setGroup_id(message.getGroup_id());
        params.setMessage("bbb 签到成功!");
        params.setMessage_type(message.getMessage_type());
        params.setAuto_escape(true);
        paramsRequest.setParams(params);
        Client.sendMessage(JSONObject.toJSONString(paramsRequest));
        return true;
    }
}
